package me.frank.security.config;

import me.frank.security.properties.SecurityProperties;
import me.frank.security.validate.code.ImageCodeGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author Frank Wang
 * @Description:
 * @Date 2018/12/12 14:42
 */
@Configuration
public class ValidateCodeBeanConfig {

    @Autowired
    private SecurityProperties securityProperties;

    @Bean
    @ConditionalOnMissingBean(value = ImageCodeGenerator.class)
    public ImageCodeGenerator imageCodeGenerator(){
        ImageCodeGenerator generator=new ImageCodeGenerator();
        generator.setSecurityProperties(securityProperties);
        return generator;
    }

}
